package cn.cxq;

import java.util.Scanner;

public class Client {

    public static void main(String[] args) {

        // 将输入拼接
        Table table;
        String databaseName;
        try (Scanner scanner = new Scanner(System.in)) {
            StringBuilder buffer = new StringBuilder();

            System.out.println("请输入Oracle建表语句：");
            while (true) {
                String line = scanner.nextLine();
                if (line.equals("")) break;
                buffer.append(line);
            }

            String oracleSql = buffer.toString();
            oracleSql = oracleSql.replaceAll(" +", " ");


            table = OracleSQLUtil.getTable(oracleSql);

            System.out.println("请输入数据库名称:");
            databaseName = scanner.nextLine();


//            String hiveSQL = HiveSQLUtil.convertIntoHiveSQL(table, databaseName);
//
//            System.out.println("执行成功，结果如下");
//            System.out.println(hiveSQL);

            System.out.println("请输入数据库用户名:");
            String username = scanner.nextLine();

            System.out.println("请输入数据库密码:");
            String password = scanner.nextLine();

            System.out.println("请输入数据库url:");
            String url = scanner.nextLine();

            String job = DataXUtil.getJob(table, username, password, url, databaseName);

            System.out.println(job);

        } catch (Exception e) {
            System.out.println("错误！！！！");
        }
    }
}
